import Vue from 'vue'
 
Vue.directive('watermark',(el,binding)=>{
    function addWaterMarker(str,parentNode,font,textColor){// 水印文字，父元素，字体，文字颜色
        var can = document.createElement('canvas');
        parentNode.appendChild(can);
        can.width = 300;
        can.height = 200;
        can.style.display = 'none';
        can.lineWidth = 1
        var cans = can.getContext('2d');
        cans.rotate(-45 * Math.PI / 180);
        cans.font = font || "16px Microsoft JhengHei";
        cans.fillStyle = textColor || "rgba(180, 180, 180, 0.3)";
        cans.textAlign = 'right';
        cans.textBaseline = 'Middle';
        cans.fillText(str, can.width / 3, can.height / 2);
        parentNode.style.backgroundImage = "url(" + can.toDataURL("image/png") + ")";
       
    }
    let flagBox=document.getElementById('flagBox')

     if(flagBox.dataset.flag==='1'){
    window.console.log(1111,flagBox.dataset.flag)
    addWaterMarker(binding.value.text, el, binding.value.font, binding.value.textColor)
     }
    
})